package cqrtplm.entity;

import java.math.BigDecimal;
import java.util.Date;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.hustcad.plm.basic.entity.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 需求状态对象 rt_cfg_demand_orders
 *
 * @author 江小雄
 * @date 2025-06-26
 */
@Data
@TableName(value = "RT_CFG_DEMAND_ORDERS", autoResultMap = true)
@JsonInclude(JsonInclude.Include.ALWAYS)
public class RtCfgDemandOrders
{
    private static final long serialVersionUID = 1L;

    //主键id
    private String id;

    //需求表主键id
    private String statusid;

    //流程编码
    private String flowCode;

    /** 产品类别 */
    @Excel(name = "产品类别")
    private String category;

    /** 需求编码 */
    @Excel(name = "需求编码")
    private String demandCode;

    /** 需求类型 */
    @Excel(name = "需求类型")
    private String demandType;

    /** 创建人 */
    @Excel(name = "创建人")
    private String creator;

    /** 客户 */
    @Excel(name = "客户")
    private String customer;

    /** 销售国 */
    @Excel(name = "销售国")
    private String salesCountry;

    /** 开发令 */
    @Excel(name = "开发令")
    private String developmentOrder;

    /** 机型 */
    @Excel(name = "机型")
    private String model;

    /** 数量 */
    @Excel(name = "数量")
    private BigDecimal quantity;

    /** 等级 */
    @Excel(name = "等级")
    private String demLevel;

    /** 客户交期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "客户交期", width = 30)
    private Date customerDeliveryDate;

    /** 任务状态 */
    @Excel(name = "任务状态")
    private Integer taskStatus;

    /** 接单时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "接单时间", width = 30)
    private Date orderReceivedTime;

    /** 订单周期 */
    @Excel(name = "订单周期")
    private Long orderCycle;

    /** 开始处理时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "开始处理时间", width = 30)
    private Date startProcessingTime;

    /** 预估完成时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "预估完成时间", width = 30)
    private Date estimatedCompletionTime;

    /** 实际完成时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "实际完成时间", width = 30)
    private Date actualCompletionTime;

    /** 当前节点 */
    @Excel(name = "当前节点")
    private String currentNode;

    /** 当前节点接收时间 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "当前节点接收时间", width = 30)
    private Date currentNodeReceivedTime;

    /** 变更/延期原因说明 */
    @Excel(name = "变更/延期原因说明")
    private String changeDelayReason;

    /** 终端工厂 */
    @Excel(name = "终端工厂")
    private String terminalFactory;

    /** 动力工厂 */
    @Excel(name = "动力工厂")
    private String powerFactory;

    /** 需求类别 */
    @Excel(name = "需求类别")
    private String demandCategory;

    /** 改在途 */
    @Excel(name = "改在途")
    private String modifiedInTransit;

    /** 在途订单 */
    @Excel(name = "在途订单")
    private String inTransitOrder;

    /** 线别 */
    @Excel(name = "线别")
    private String productionLine;

    /** 需求编码 */
    @Excel(name = "需求编码")
    private String demandCodeDuplicate;

    /** 参照裸机码 */
    @Excel(name = "参照裸机码")
    private String bareMachineCodeReference;

    /** 参照成品码 */
    @Excel(name = "参照成品码")
    private String finishedProductCodeReference;

    /** 配置 */
    @Excel(name = "配置")
    private String configuration;

    /** 组动单包 */
    @Excel(name = "组动单包")
    private String assemblyPackage;

    /** 无需动力 */
    @Excel(name = "无需动力")
    private String noPowerRequired;

    /** 包装组 */
    @Excel(name = "包装组")
    private String packagingGroup;

    /** 贴花组 */
    @Excel(name = "贴花组")
    private String stickerGroup;

    /** 检小批 */
    @Excel(name = "检小批")
    private String inspectionSmallBatch;


    /** 变更单号 */
    @Excel(name = "变更单号")
    private String changeOrder;

    public RtCfgDemandOrders(){

    }

    public RtCfgDemandOrders(RtCfgStatusInfoDO rtCfgStatusInfoDO,String flowCode){
        this.statusid = rtCfgStatusInfoDO.getStatusid();
        this.flowCode = flowCode;
        this.category = rtCfgStatusInfoDO.getProductclass()==0?"动力":"终端";
        this.demandCode = rtCfgStatusInfoDO.getStatuscode();
        this.demandType = String.valueOf(rtCfgStatusInfoDO.getIsprototype());
        this.creator = rtCfgStatusInfoDO.getFcreateusername();
        this.customer = rtCfgStatusInfoDO.getCustomecode();
        this.salesCountry = rtCfgStatusInfoDO.getSaletocountry();
        this.developmentOrder = rtCfgStatusInfoDO.getDevcode();
        this.model = rtCfgStatusInfoDO.getProducttype();
        this.quantity = rtCfgStatusInfoDO.getOrderamount();
        this.demLevel = rtCfgStatusInfoDO.getPriority();
        this.taskStatus = rtCfgStatusInfoDO.getFlowstatus();
        this.terminalFactory = rtCfgStatusInfoDO.getTerminalfactory();
        this.powerFactory = rtCfgStatusInfoDO.getPowerfactory();
        this.demandCategory = rtCfgStatusInfoDO.getIsprototype().toString();
        this.demandCodeDuplicate = rtCfgStatusInfoDO.getStatuscode();
        this.bareMachineCodeReference = rtCfgStatusInfoDO.getEbomDescr();
        this.finishedProductCodeReference = rtCfgStatusInfoDO.getRefermbomcode();
        if(StrUtil.isNotEmpty(rtCfgStatusInfoDO.getDevcode())){
            this.productionLine=rtCfgStatusInfoDO.getDevcode().substring(0,1);
        }
        this.bareMachineCodeReference = rtCfgStatusInfoDO.getEbomcode();
    }

}
